package com.androidbook.garbagedemo1.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Looper;
import android.widget.Toast;
import android.widget.Toolbar;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.llw.mvplibrary.network.utils.StatusBarUtil;

public class BaseActivity extends AppCompatActivity {

    public Context mContext;

    @Override
    protected  void onCreate(@Nullable Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        mContext=this;
    }


    //对Toast提示方法进行封装
    public void showToast(String msg){
        Toast.makeText(mContext,msg,Toast.LENGTH_SHORT).show();
    }

    //对页面跳转方法进行封装
    public void navigateTo(Class cls){
        Intent in =new Intent(mContext,cls);
        startActivity(in);
    }

    //对子线程Toast提示方法进行封装
    public void showToastSync(String msg){
        Looper.prepare();
        Toast.makeText(mContext,msg,Toast.LENGTH_SHORT).show();
        Looper.loop();

    }

    //
    protected void saveStringToSp(String key,String val){
        SharedPreferences sp = getSharedPreferences ("sp_ttit",MODE_PRIVATE);
        SharedPreferences.Editor editor =sp.edit();
        editor.putString ( key, val);
        editor.commit();
    }





}
